package org.tzw.template.utils;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 创建线程池
 */
public class ThreadPool {
    public static ThreadPoolExecutor executor;

    static {
        int i = Runtime.getRuntime().availableProcessors();
        executor = new ThreadPoolExecutor(3, i + 1, 3, TimeUnit.SECONDS
                , new LinkedBlockingQueue<>(30), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
    }
}
